import urllib.request
import os
def download_text(file_path):
    url = ("https://raw.githubusercontent.com/rasbt/"
        "LLMs-from-scratch/main/ch02/01_main-chapter-code/"
        "the-verdict.txt")
    urllib.request.urlretrieve(url, file_path)

def load_text():
    file_path = "the-verdict.txt"
    if not os.path.exists(file_path):
        download_text(file_path)
    with open(file_path, "r", encoding="utf-8") as f:
        text = f.read()
    return text


if __name__ == "__main__":
    text = load_text()
    print("total characters: ", len(text))
    print(text[:50])